/*--------------------------------------------------
file name  : prj_defines.sv
created    : 2025/08/16 18:05:01
description: 
notes      : 
author     : yyrwkk
--------------------------------------------------*/
`ifndef PRJ_DEFINES_SV
`define PRJ_DEFINES_SV

// log 
`define prj_fatal(str,id=get_type_name())   `uvm_fatal(id,str)
`define prj_error(str,id=get_type_name())   `uvm_error(id,str)
`define prj_warning(str,id=get_type_name()) `uvm_warning(id,str)

`define prj_none(str, id=get_type_name())   `uvm_info(id,str,UVM_NONE)
`define prj_low(str, id=get_type_name())    `uvm_info(id,str,UVM_LOW)
`define prj_medium(str, id=get_type_name()) `uvm_info(id,str,UVM_MEDIUM)
`define prj_high(str, id=get_type_name())   `uvm_info(id,str,UVM_HIGH)
`define prj_full(str, id=get_type_name())   `uvm_info(id,str,UVM_FULL)
`define prj_debug(str, id=get_type_name())  `uvm_info(id,str,UVM_DEBUG)

// assertion 
`define assert_handshake(clk, rst_n, name, vld, data, rdy)      \
    property p_``name``_vld;                                    \
        @(posedge clk) disable iff( !rst_n )                    \
        not $isunknown(vld);                                    \
    endproperty                                                 \
                                                                \
    property p_``name``_rdy;                                    \
        @(posedge clk) disable iff( !rst_n )                    \
        not $isunknown(rdy);                                    \
    endproperty                                                 \
                                                                \
    property p_``name``_data;                                   \
        @(posedge clk) disable iff( !rst_n )                    \
        vld |-> not $isunknown(data);                           \
    endproperty                                                 \
                                                                \
    property p_``name``_data_stable;                            \
        @(posedge clk) disable iff( !rst_n )                    \
        (vld & ~rdy) |=> $stable(data);                         \
    endproperty                                                 \
                                                                \
    a_``name``_vld         : assert property( p_``name``_vld        )    \
                             else `uvm_fatal(`"p_``name``_vld`",`"``vld`` have x/z state!`") \
    a_``name``_rdy         : assert property( p_``name``_rdy        )    \
                             else `uvm_fatal(`"p_``name``_rdy`",`"``rdy`` have x/z state!`") \
    a_``name``_data        : assert property( p_``name``_data       )    \
                             else `uvm_fatal(`"p_``name``_data`",`"when ``vld`` is valid, the ``data`` have x/z state!`") \
    a_``name``_data_stable : assert property( p_``name``_data_stable)    \
                             else `uvm_fatal(`"p_``name``_data_stable`",`"when handshake not finish, ``data`` changed!`") \
    c_``name``_data_stable : cover  property( p_``name``_data_stable); 





`endif

